import request from '@/utils/request'
import {formatDateTime} from '@/utils/dateUtil'
const api = {}
// 日志任务列表
 api.getLogList = data => {
    let p = request({
      url: `/log/quartzLogs/query`,
      method: 'get',
      params: data
    })

    p = p.then(res=>{
      let page = res.data.page
      page.list.forEach(e => {
        e.createTime = formatDateTime(e.createTime)
      });
      return page
    })
    return p
  }

  
  api.getAllTitle = (data) => {
    return request({
      url: `/log/quartzLogs/getAllTitle`,
      method: 'get',
      params: data
    })
  }

  //定时任务调度日志列表查询
  api.query = (data) => {
   let item= request({
      url: `/log/jobTaskLog/query`,
      method: 'get',
      params: data
    })
    item.then(res=>{
      res.data.page.list.forEach(e=>{
        e.createTime = formatDateTime(e.createTime)
      });
      
    })
    return item
  }

  //定时任务调度日志菜单
  api.getListJobName = (data) => {
    let p = request({
      url: `/base/jobTask/getListJobName`,
      method: 'get',
      params: data
    })
    p = p.then(res=>{
      let list = res.data.list
      
      list.forEach(e=>{
        e.title = e.jobName
        e.jobName = `${e.jobName}(${e.cronExpress})`
        if(e.enable==1){
          e.jobName = '【启用】'+e.jobName;
        } else {
          e.jobName = '【禁用】'+e.jobName;
        }
      })
      return list
    })
    return p
  }

  export default api